<template>
	<view class="usercenter">
		<view class="usercenter__userinfo">
			<u-avatar :src="src"></u-avatar>
			<u--text margin="20rpx 0 0 0" bold :text="username"></u--text>
		</view>
		<view class="usercenter__card">
			<view class="usercenter__card-header">
				全部订单
			</view>
			<view class="usercenter__card-content">
				<view class="usercenter__card-content-item" v-for="(item,index) in orderList"
					style="margin: 0 0rpx;width: 140rpx;" :key="index">
					<u-icon labelPos="bottom" :label="item.label" size="30" :name="item.icon"
						@click="toOrderPage(item)"></u-icon>
				</view>
			</view>
		</view>
		<view class="usercenter__card">
			<view class="usercenter__card-header">
				常用
			</view>
			<view class="usercenter__card-content">
				<view class="usercenter__card-content-item" v-for="(item,index) in otherList"
					style="margin: 0 0rpx; width: 140rpx;" :key="index">
					<u-icon labelPos="bottom" :label="item.label" size="30" :name="item.icon"
						@click="toPage(item)"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
				username: '用户1',
				orderList: [{
						label: '待付款',
						icon: 'bookmark',
						query: {
							status: 1
						},
					},
					{
						label: '待发货',
						icon: 'car',
						query: {
							status: 2
						},
					},
					{
						label: '待收货',
						icon: 'list-dot',
						query: {
							status: 3
						},
					},
					{
						label: '待提货',
						icon: 'order',
						query: {
							status: 4
						},
					},
					{
						label: '退款售后',
						icon: 'red-packet',
						query: {
							status: 5
						},
					},
				],
				otherList: [{
						label: '收货地址',
						icon: 'map',
						path: '/pages/address/address',
					},
					{
						label: '团购券',
						icon: 'coupon',
						path: '/pages/coupon/coupon',
					},
				]
			}
		},
		methods: {
			toOrderPage(item) {
				getApp().globalData.orderStatus = item.query.status
				uni.$u.route({
					url: '/pages/mainPage/order/order',
					type: 'tab'
				})
			},
			toPage(item) {
				uni.$u.route({
					url: item.path
				})
			}
		}
	}
</script>

<style lang="scss">
	.usercenter__userinfo {
		height: 240rpx;
		background-color: #fff;
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
	}

	.usercenter__card {
		height: 250rpx;
		background-color: #fff;
		border-radius: 18rpx;
		margin: 30rpx 0;
		padding: 0 30rpx;

		&-header {
			padding: 30rpx 0 20rpx;
			font-size: 34rpx;
		}

		&-content {
			display: flex;
			flex-direction: row;
		}
	}
</style>